package com.hmall.item.mq;
import com.hmall.item.service.searchService;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class Hmaliestener {

    @Autowired
    searchService service;
    /**
     * 监听酒店新增或修改的业务
     * @param id
     */
//    @RabbitListener(queues = MqConstants.HOTEL_INSERT_QUEUE)
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("insert.queue"),
            exchange = @Exchange(value = "item.topic",type = ExchangeTypes.TOPIC),
            key = "item.insert"
    ))
    public void listentHoteInnerOrderUpdate(Long id){
        service.inserById(id);
    }



    /**
     *
     * 监听酒店删除业务
     * @param id
     */
//    @RabbitListener(queues = MqConstants.HOTEL_DELETE_QUEUE)
     @RabbitListener(bindings = @QueueBinding(
             value = @Queue("delete.queue"),
             exchange = @Exchange(value = "item.topic",type = ExchangeTypes.TOPIC),
             key = "item.delete"
     ))
    public void listHoteDekete(Long id){
        service.deleById(id);
    }


}
